﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;

//using PowerCreator.LMS.Logic.ProjectManager;
//using PowerCreator.LMS.Logic.Common;


public partial class sysadmin_CountManager_FCProjectPassCount : PowerCreator.LMS.Web.Base.BasePage
{
    #region XML数据模版

    //图表抬头 Title, xAxisName=X轴的名称，yAxisName=y轴显示的名称,yAxisMaxValue=y轴最大值
    //柱形图
    const string GRAPH = "<graph  caption='单个方案统计'  xAxisName='单个方案统计信息' yAxisName='{0}' decimalPrecision='0' formatNumberScale='0' baseFontSize='14' yAxisMaxValue='100' > ";
    //名称，值，颜色
    const string GRAPH_TR = "<set name='{0}' value='{1}' color='{2}' />";
    const string GRAPH_END = "</graph>";
    const string REPORT_URL = "/FusionCharts/FCF_Column3D.swf";

    //3D饼图
    const string VIEW_START = "<graph showNames='1'  decimalPrecision='0' baseFontSize='14'>";
    const string VIEW_DATA_TD = "<set name='{0}' value='{1}' />";
    const string VIEW_END = "</graph>";
    const string VIEW_URL = "/FusionCharts/FCF_Pie3D.swf";
    #endregion

    
    //参加学习方案人数
    const string SEARCH_PROJECT_COUNT = " and ProjectID={0} ";

    //ManagerProjectInfo projectManager = new ManagerProjectInfo();
    //ManagerProjectHistoryInfo projectHistoryManager = new ManagerProjectHistoryInfo();

    //查询ProjectHistory表的通过人数
    const string SEARCH_PROJECTHISTORY_COUNT_NOPASS = " ProjectID={0} and State<>{1}";

    //查询ProjectHistory表的未通过人数
    const string SEARCH_PROJECTHISTORY_COUNT_PASS = " ProjectID={0} and State={1}";

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //string pid = Base64.Decode(Request.QueryString["p"].ToString());
            //ViewState["ProjectID"] = pid;
            //string url = Utils.WebRoot + VIEW_URL;
            //string xml = GetXMLPie3D();
            //if (!string.IsNullOrEmpty(xml))
            //{
            //    Literal1.Text = InfoSoftGlobal.FusionCharts.RenderChartHTML(url, "", xml, "myxml", "800", "400", false);
            //}
            //else
            //{
            //    Literal1.Text = "目前没有该方案的统计信息";
            //}
        }
    }

    public string GetXMLPie3D()
    {
        //int allProjectUser = projectManager.UserStudentProjectListCount(string.Format(SEARCH_PROJECT_COUNT, ViewState["ProjectID"]));
        //int nopass = projectHistoryManager.Count(string.Format(SEARCH_PROJECTHISTORY_COUNT_NOPASS, ViewState["ProjectID"], 3));
        //int yespass = projectHistoryManager.Count(string.Format(SEARCH_PROJECTHISTORY_COUNT_PASS, ViewState["ProjectID"], 3));
        //PowerCreator.LMS.Model.Entity.ProjectInfo pinfo = new PowerCreator.LMS.Model.Entity.ProjectInfo();
        //pinfo = projectManager.Load(int.Parse(ViewState["ProjectID"].ToString()));
        StringBuilder sbXml = new StringBuilder();
        //if (nopass+yespass == 0)
        //{
        //    return "";
        //}
        //else
        //{
        //    sbXml.Append(string.Format(VIEW_START, pinfo.ProjectName));
        //    //sbXml.Append(string.Format(VIEW_DATA_TD, "参加总人数", allProjectUser));
        //    sbXml.Append(string.Format(VIEW_DATA_TD, "己通过人数", yespass));
        //    sbXml.Append(string.Format(VIEW_DATA_TD, "未通过人数", nopass));
        //    sbXml.Append(VIEW_END);
        //}
        return sbXml.ToString();
    }

    public string GetXml()
    {
        //int allProjectUser = projectManager.UserStudentProjectListCount(string.Format(SEARCH_PROJECT_COUNT,ViewState["ProjectID"]));
        //int nopass = projectHistoryManager.Count(string.Format(SEARCH_PROJECTHISTORY_COUNT_NOPASS,ViewState["ProjectID"],2));
        //int yespass = projectHistoryManager.Count(string.Format(SEARCH_PROJECTHISTORY_COUNT_NOPASS, ViewState["ProjectID"],3));
        //PowerCreator.LMS.Model.Entity.ProjectInfo pinfo = new PowerCreator.LMS.Model.Entity.ProjectInfo();
        //pinfo = projectManager.Load(int.Parse(ViewState["ProjectID"].ToString()));
        StringBuilder sbXml = new StringBuilder();
        //if (allProjectUser == 0 )
        //{
        //    return "";
        //}
        //else
        //{
        //    sbXml.Append(string.Format(GRAPH, pinfo.ProjectName));
        //    sbXml.Append(string.Format(GRAPH_TR, "参加总人数", allProjectUser, ReportUtils.GetColorRander(6)));
        //    sbXml.Append(string.Format(GRAPH_TR, "己通过人数", yespass, ReportUtils.GetColorRander(6)));
        //    sbXml.Append(string.Format(GRAPH_TR, "未通过人数", nopass, ReportUtils.GetColorRander(6)));
        //    sbXml.Append(GRAPH_END);            
        //}
        return sbXml.ToString();
    }    
}
